home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10731 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.1 KB  |  79 lines

  1. Path: news.bellglobal.com!news
  2. From: montagp@execulink.com (Paul Montag)
  3. Newsgroups: comp.lang.c++
  4. Subject: File Access
  5. Date: 9 Mar 1996 02:59:46 GMT
  6. Organization: Bell Global Solutions
  7. Message-ID: <4hqs72$ci4@news.bellglobal.com>
  8. NNTP-Posting-Host: ppp30.execulink.com
  9. Mime-Version: 1.0
  10. Content-Type: Text/Plain; charset=ISO-8859-1
  11. X-Newsreader: WinVN 0.99.5
  12.  
  13. Hi.  I am trying to access a Pascal created data file with the following 
  14. record format:
  15.  
  16.   MSGTOIDXrecord = string[35];
  17.  
  18.   USERONrecord   = record
  19.                      Name,
  20.                      Handle         : MSGTOIDXrecord;
  21.                      Line           : Byte;
  22.                      Baud           : Word;
  23.                      City           : String[25];
  24.                      Status,
  25.                      Attribute      : Byte;
  26.                      StatDesc       : String[10];
  27.                      FreeSpace      : Array[1..98] of Byte;
  28.                      NoCalls        : Word;
  29.                    end;
  30.  
  31.  
  32.  
  33. Multiple records of this type could be contained in this file however I am not 
  34. really worried about this right now.  Here is what I have in C++ so far:
  35.  
  36. /**************************************************************************/
  37.  
  38. #include <iostream.h>
  39. #include <fstream.h>
  40. #include <string.h>
  41.  
  42. struct USERONtype
  43.    {
  44.    char           Name[35],Handle[35];  //PRETTY SURE THIS IS RIGHT!
  45.    unsigned       Line;
  46.    char           City[25];
  47.    unsigned char  Status, Attribute;
  48.    char           StatDesc[10];
  49.    unsigned char  FreeSpace[97];
  50.    unsigned int   NoCalls;
  51.    };
  52.  
  53.  
  54. int main (void)
  55.    {
  56.    USERONtype UserOn;
  57.  
  58.    ifstream inFile ("e:\\ra\\useron.bbs", ios::binary);
  59.  
  60.    inFile.get (UserOn.Name, 35);    // <- NOT SURE ABOUT HOW TO READ IN THE
  61.                     // Information.  
  62.  
  63.    inFile.close();
  64.  
  65.    return 0;
  66.    }
  67.  
  68. /**************************************************************************/
  69.  
  70. I have worked with files in CPP before, just random access files(at least 
  71. thats what I think this is called) that store records like this.  If anyone 
  72. has any ideas please let me know.  Thanks!!!
  73.  
  74.  
  75. Paul Montag
  76. Internet: montagp@execulink.com
  77. FidoNet: 1:2401/501
  78.  
  79.